//Page 449 

#include <vector>
#include <iostream>
#include <iterator>
#include <deque>
#include <list>
#include <algorithm>

using namespace std ;

int a[] = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 } ;

template <typename Cont>
void frontInsertion( Cont & ci )
{
	copy ( a, a + sizeof a/ sizeof(typename Cont::value_type), front_inserter(ci) ) ;
	copy ( ci.begin(), ci.end(), ostream_iterator<typename Cont::value_type>(cout, " ") ) ;
	cout << endl ;
}

template <typename Cont>
void backInsertion( Cont & ci )
{
	copy ( a, a + sizeof a/ sizeof(typename Cont::value_type), back_inserter(ci) ) ;
	copy ( ci.begin(), ci.end(), ostream_iterator<typename Cont::value_type>(cout, " ") ) ;
	cout << endl ;
}

template <typename Cont>
void midInsertion( Cont & ci )
{
	typename Cont::iterator it = ci.begin() ;
	++it; ++it; ++it;
	
	copy ( a, a + sizeof a / (sizeof(typename Cont::value_type)*2), inserter(ci, it) ) ;
	copy ( ci.begin(), ci.end(), ostream_iterator<typename Cont::value_type>(cout, " ") ) ;
	cout << endl ;
}

int main ( )
{
	deque<int>  di ;
	list<int>   li ;
	vector<int> vi ;

	frontInsertion(di) ;
	frontInsertion(li) ;

	di.clear() ;
	li.clear() ;

	backInsertion ( vi ) ;
	backInsertion ( di ) ;
	backInsertion ( li ) ;

	midInsertion ( vi ) ;
	midInsertion ( di ) ;
	midInsertion ( li ) ;

	return 0 ;
}
